  
 /**
  	Author	    : Basha
  	Date 	    : March 1 , 2005
  	Description : This proc is used to save the System prferences details
 	Usage       : exec sp_save_system_preferences
 
  */

ALTER  PROCEDURE sp_save_system_preferences
 (
 @BUILD_MASTER_CAN_OVERRIDE_SFC   INT,
 @PART_NUMBER_TYPE   INT,
 @PRICE_PULL INT,
 @MODIFIEDBY    VARCHAR(50),
 @ERROR_CODE 	BIT OUTPUT
 )
 AS
 BEGIN

	-- SELECT SYSTEMPRFID, BUILD_MASTER_CAN_OVERRIDE_SFC, PART_NUMBER_TYPE, MODIFIED_BY, MODIFIED_ON FROM SYSTEMPRFS

 	--DECLARATIONS
 	DECLARE @CURRENT_DATE DATETIME
 	DECLARE @SYSTEMPRFID INT
 	--INITIALISATIONS
 	SET @ERROR_CODE = 1
 	SET @CURRENT_DATE =  getDate()
        
 	SELECT @SYSTEMPRFID = SYSTEMPRFID FROM SYSTEMPRFS 
 	IF( @@ROWCOUNT = 0 )
 	BEGIN
 		-- INSERTING SYSTEM PREFERENCES IN TO THE SYSTEM_PREFS TABLE
 		INSERT INTO SYSTEMPRFS ( BUILD_MASTER_CAN_OVERRIDE_SFC, PART_NUMBER_TYPE, PRICE_PULL, MODIFIED_BY, MODIFIED_ON ) 
		VALUES ( @BUILD_MASTER_CAN_OVERRIDE_SFC, @PART_NUMBER_TYPE, @PRICE_PULL, @MODIFIEDBY, @CURRENT_DATE )
 	END
 	ELSE
 	BEGIN
 		--UPDATING THE SYSTEM PREFERENCES IN THE SYSTEM_PREFS TABLE
 		UPDATE SYSTEMPRFS SET BUILD_MASTER_CAN_OVERRIDE_SFC =  @BUILD_MASTER_CAN_OVERRIDE_SFC, PART_NUMBER_TYPE = @PART_NUMBER_TYPE, PRICE_PULL = @PRICE_PULL, MODIFIED_BY = @MODIFIEDBY, MODIFIED_ON = @CURRENT_DATE  WHERE SYSTEMPRFID = @SYSTEMPRFID
 	END
 
 	SET @ERROR_CODE = 0 --PROC HAS EXECUTED SUCCESSFULLY, SO SETTING THE ERROR CODE AS 0
 
 END --End of Proc
 
  


